<?php
// Test file used for receiving data from ThreeTimesError using http get.
// The content of the file will be written to the path specified in $file.
// A CSRF token must be provided and must match the token specified in $savedToken.

$file = "data.txt";

$token = $_GET["token"];
$savedToken = "myToken";
if($token != $savedToken) {
	return;
}

$get = $_GET;
if(empty($get)) { die(); }
$output = "";
foreach ($get as $key => $value) {
	$output = $output . "" . $key . ": \"" . $value . "\"\r\n";
}

$file = fopen($file, "a") or die("could not open file");
fwrite($file, date("Y-m-d H:i:s"));
fwrite($file, "\r\n");
fwrite($file, $output);
fwrite($file, "User agent: " . $_SERVER['HTTP_USER_AGENT']);
fwrite($file, "\r\n");
fwrite($file, "IP: " . $_SERVER['REMOTE_ADDR']);
fwrite($file, "\r\n");
fwrite($file, "=======================");
fwrite($file, "\r\n");
fclose($file);

header('Content-type: text/javascript');
?>